<!DOCTYPE html>
<html>
<head>
    <title>模具档案信息</title>
    #parse("sys/header.html")
</head>
<body>
<div id="rrapp" v-cloak>
    <div>
        <Row :gutter="16" style="margin: 8px 0px 0px 1px">
            <div class="search-group">
                <i-col span="4">
                    <i-input v-model="q.moduleNo" @on-enter="query" placeholder="模具号"></i-input>
                </i-col>
                <i-button @click="query">查询</i-button>
                <i-button @click="reloadSearch">重置</i-button>
            </div>
        </Row>
        <table id="jqGrid"></table>
    </div>
</div>
<script>
    $(function () {
        $("#jqGrid").Grid({
            url: '../modulearchives/listAvailable',
            colModel: [
                {label: '模具编码', name: 'moduleCode', index: 'MODULE_CODE', width: 120},
                {label: '模具号', name: 'moduleNo', index: 'MODULE_NO', width: 120},
                {label: '模具类型', name: 'moduleTypeName', index: 'MODULE_TYPE', width: 80},
                {label: '模具类型', name: 'moduleType', index: 'MODULE_TYPE', hidden: true},
                {label: '模具机型', name: 'productModelName', index: 'PRODUCT_MODEL', width: 80},
                {label: '寿命标准', name: 'xiangkuaiLifeStandard', index: 'XIANGKUAI_LIFE_STANDARD', width: 80},
                {label: '所在车间', name: 'subShopName', index: 'SUB_SHOP_NAME', width: 80},
                {label: '车间id', name: 'subShop', index: 'SUB_SHOP', width: 80, hidden: true},
                {label: '启用时间', name: 'startDate', index: 'START_DATE', width: 80,
                    formatter: function (value) {
                        return transDate(value,"yyyy-MM-dd");
                    }
                },
                {label: '当前状态', name: 'currentState', index: 'CURRENT_STATE', width: 80,
                    formatter: function (value) {
                        return sysEnums.MODULE_STATE[value];
                    }
                },
                {label: '剩余次数', name: 'xiangkuaiRemainNo', index: 'XIANGKUAI_USE_NO', width: 80},
                {label: '镶块使用次数', name: 'xiangkuaiUseNo', index: 'XIANGKUAI_USE_NO', width: 80},
                {name: 'moduleCategory', hidden: true},
                {name: 'moduleSeries', hidden: true},
                {name: 'moduleModel', hidden: true},
                {name: 'firmCapitalNo', hidden: true},
                {label: 'id', name: 'id', index: 'ID', key: true, hidden: true},
            ]
        });

    });

    let vm = new Vue({
        el: '#rrapp',
        data: {
            moduleArchives: {lifeStandard:'', productModel:'', moduleNo:'', moduleType:'', moduleCode:'', id:'', updateDate:'', updateUser:'', createDate:'', createUser:'', delFlag:'',
                moduleModel:'', moduleSeries:'', moduleCategory:'', isData:'', firmCapitalNo:'', useNo:'', remainNo:'', currentState:'', startDate:'', subShop:'', moduleTypeName: ''  },
            ruleValidate: {
                name: [
                    {required: true, message: '名称不能为空', trigger: 'blur'}
                ]
            },
            q: {
                moduleNo: ''
            },
            currentStateArray: enumsToList("MODULE_STATE"),
        },
        methods: {
            query: function () {
                vm.reload();
            },
            reload: function (event) {
                vm.showList = true;
                let page = $("#jqGrid").jqGrid('getGridParam', 'page');
                $("#jqGrid").jqGrid('setGridParam', {
                    postData: {'moduleNo': vm.q.moduleNo},
                    page: page
                }).trigger("reloadGrid");
            },
            reloadSearch: function() {
                vm.q = {
                    moduleNo: ''
                };
                vm.reload();
            },
            handleReset: function (name) {
                handleResetForm(this, name);
            }
        }
    });
    var getModuleArchives = function () {
        let result = getSelectedRowData("#jqGrid");
        var id = result.id;
        if (id == null) {
            return false;
        } else {
            return result;
        }
    }
    var getSelectedModuleArchivesList = function () {
        let result = getSelectedRowDatas("#jqGrid");
        if (!result || result.length == 0) {
            return false;
        } else {
            return result;
        }
    }
</script>
</body>
</html>
